home *** CD-ROM | disk | FTP | other *** search
- [ Level-4 registration routine ]
- --------------------------------
-
- I will not post the step-by-step solution this time. You'll have to
- figure out this one yourself. I believe you should have enough practice.
- But here are a few pointers...
-
- First, unlike the previous registration routines, this one involves a
- funtion call. That means, when you encounter the "call ..." you will
- need to use the [F8] command in Softice to trace INTO the function.
- Other than that, there isn't much difference. But noticed that
- a string comparing function is not used here. I wrote my own
- instructions to compare the two strings (generated key & the key entered),
- but it should be relatively simple.
-
- Try not to look at the solution code before you even attempt to hack it.
-
- Good Luck!
-
-
-
-
- Actual C++ codes, Solution
- ---------------------------
-
- void CCrackMeDlg::Validate()
- {
- int i = 0, slen = 0;
- DWORD value1 = 0, value2 = 0;
- CString usrn = "", key = "";
- char keystr[30] = "\0";
-
- GetDlgItemText(IDC_USRN, usrn); // username entered
- GetDlgItemText(IDC_KEY, key); // key/password entered
- slen = usrn.GetLength();
- if ((slen < 5) || (slen > 256))
- {
- MessageBox("User Name must be between 5 to 256 characters.",
- "CrackMe", MB_OK | MB_ICONINFORMATION);
- return;
- }
- if (key.IsEmpty())
- return; // quit if empty key
- Get2Values(usrn, slen, value1, value2); // function call!!!
- wsprintf(keystr, "%lu-%X", value1, value2);
- // print values to string "keystr" as unsigned long & hex digits
- slen = lstrlen(keystr);
- key.MakeReverse();
- do
- {
- if (i < key.GetLength())
- {
- if (key[i] != keystr[i])
- break;
- }
- i++;
- } while (keystr[i] > 0);
- if ((i - slen) == 0)
- // correct key
- else
- // incorrect key
- }
-
- void CCrackMeDlg::Get2Values(CString &usrn, int slen, DWORD &value1, DWORD &value2)
- {
- register int i;
- for (i = 0; i < slen; i++)
- {
- if ((i % 2) != 0)
- value1 = GetValue(usrn, slen, value2+i);
- else
- value2 = GetValue(usrn, slen, value1+i);
- }
- }
-
- DWORD CCrackMeDlg::GetValue(CString &usrn, int slen, DWORD value)
- {
- register int i, j;
- int clen;
- DWORD retval = 1;
-
- clen = lstrlen((LPCTSTR) code1);
- for (i = 0; i < slen; i++)
- {
- retval *= usrn[i];
- for (j = 0; j < (clen/2); j++)
- retval += (code1[j] - (usrn[i] % (j+1)) + code1[clen-j-1]);
- retval *= (i+1);
- retval <<= 8;
- retval ^= value;
- }
- return (retval);
- }
-